#pragma once
#include<iostream>
#include<pthread.h>

class Task
{
	private:
		int x;
		int y;
		char op;
	public:
		Task(){}
		Task(int _x,int _y,char _op):x(_x),y(_y),op(_op){}
		void operator()()
		{
			run();
		}
		void run()
		{
			int z = -1;
			switch(op)
			{
				case '+':
					z = x+y;
					break;
				case '-':
					z = x-y;
					break;
				case '*':
					z = x*y;
					break;
				case '/':
					if(y != 0)
						z = x/y;
					else
						std::cout<<"Warning: div zero!"<<std::endl;
					break;
				default:
					std::cout<<"unknow operator!\n";
					break;
			}
			std::cout<<"thread"<<"["<<pthread_self()<<"] handler task done : "<<x<<op<<y<<"="<<z<<std::endl;
		}
		~Task(){}
};
